Skip to content

BDMS-540: Add missing thing_id foreign key to NMA_WeatherData#468

Merged
jirhiker merged 8 commits intokas-bdms-540-standardize-PKs-FKsfrom
kas-bdms-540-NMA_WeatherData-FK-relationship
Feb 7, 2026
Merged

BDMS-540: Add missing thing_id foreign key to NMA_WeatherData#468
jirhiker merged 8 commits intokas-bdms-540-standardize-PKs-FKsfrom
kas-bdms-540-NMA_WeatherData-FK-relationship

Conversation

@ksmuczynski
Copy link
Copy Markdown
Contributor

@ksmuczynski ksmuczynski commented Feb 5, 2026

Why

This PR addresses the following problem / context:

  • Adds a missing, required thing_id relationship for NMA WeatherData to ensure legacy rows link to Thing records and avoid orphaned children

How

Implementation summary - the following was changed / added / removed:

  • Added thing_id FK + relationship on NMA_WeatherData with validation
  • Updated WeatherData transfer to resolve thing_id by matching each row’s location to Thing.nma_pk_location, linking NMA_WeatherData → Thing and skipping rows without a match to avoid orphaned records.
  • Add alembic migration to backfill thing_id and enforce NOT NULL
  • update WeatherData legacy tests to include Thing linkage

Notes

Any special considerations, workarounds, or follow-up work to note?

…ablish relationship with Thing

- add thing_id FK + relationship on NMA_WeatherData with validation
- cache Thing.nma_pk_location and resolve thing_id in WeatherData transfer
- skip unlinked WeatherData rows to prevent orphaned children
- add alembic migration to backfill thing_id and enforce NOT NULL
- update WeatherData legacy tests to include Thing linkage
ksmuczynski and others added 6 commits February 5, 2026 16:23
…os and NMA_SurfaceWaterData via SurfaceID

- make NMA_SurfaceWaterData.surface_id unique to support FK target
- add FK + relationship on NMA_SurfaceWaterPhotos.surface_id with validation
- enforce parent-first ordering by running SurfaceWaterPhotos after SurfaceWaterData
- skip orphan photo rows in transfer using cached SurfaceIDs
- add migration to backfill/cleanup and enforce NOT NULL + FK
- update legacy tests to create photos with real parent SurfaceWaterData
…NMA_WeatherPhotos via WeatherID

- move weather_id under FK section and enforce NOT NULL
- add FK + relationship + validator on NMA_WeatherPhotos
- mark NMA_WeatherData.weather_id unique for FK target
- run WeatherPhotos transfer after WeatherData and skip orphan photos
- add migration to backfill/cleanup and enforce FK/NOT NULL
- update legacy tests to create WeatherPhotos with a real parent WeatherData
…atherPhotos-FK-relationship

BDMS-540: Link NMA_WeatherPhotos to NMA_WeatherData
…rfaceWaterPhotos-FK-relationship

BDMS-540: Link NMA_SurfaceWaterPhotos to NMA_SurfaceWaterData
@jirhiker jirhiker merged commit 92b5bd9 into kas-bdms-540-standardize-PKs-FKs Feb 7, 2026
4 checks passed
@TylerAdamMartinez TylerAdamMartinez deleted the kas-bdms-540-NMA_WeatherData-FK-relationship branch March 12, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants